<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Lotto</title>
<link href="../css/loto_lb.css?time=02" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
var MaxOdds = {MaxOdds};
var intTotalWNo = {intTotalWNo};
var UseCredit = {UseCreditValue};
var UseLimit = {UseLimitValue};
var chkBetLimit = {chkBetLimit};
var chkEventLimit = {chkEventLimit} - UseLimit;
var chkMaxPayOff = {MaxPayOff};
var chkMinStake = {MinStake};
var chkCredit = {ShowCredit} - UseCredit;
var PayOff = 0;
var MaxGetPayOff = 0;
var MaxPayOff = {MaxPayOff};
var noMoney = "{noMoney}";
var notNumber = "{notNumber}";
var overMaxPayOff = "{overMaxPayOff}";
var underMinStake = "{underMinStake}";
var overBetLimit = "{overBetLimit}";
var overEventLimit = "{overEventLimit}";
var overCredit = "{overCredit}";
var sureStake = "{sureStake2}";

function Calculate(){
	with(document.WagerForm){
		if(StakeMoney.value == ""){
			StakeMoney.focus();
			alert(noMoney);
			return false;
		}else{
			var flMStake = parseFloat(StakeMoney.value);
			PayOff = Math.round(flMStake*(MaxOdds - 1)*1000)/1000;
			MaxGetPayOff = Math.round(flMStake*(MaxOdds - intTotalWNo)*1000)/1000;
			document.getElementById("MaxGetPayOff").innerHTML = MaxGetPayOff.toString();
		}
	}
	return true;
}

function CheckNumKey(){
	if(event.keyCode == 13) return true;
	if((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode > 95 || event.keyCode < 106)){
		alert(notNumber);
		return false;
	}
}

function FinalCheck(){
	var objGold = document.WagerForm["StakeMoney"];
	if(!Calculate())return false;
	if(isNaN(objGold.value) == true){
		alert(notNumber);
		return false;
	}
	if(PayOff > MaxPayOff){
		alert(overMaxPayOff);
		return false;
	}
	if(eval(objGold.value) < chkMinStake){
		alert(underMinStake);
		return false;
	}
	if(eval(objGold.value) > chkBetLimit){
		alert(overBetLimit);
		return false;
	}
	if(eval(objGold.value) > chkEventLimit){
		alert(overEventLimit+chkEventLimit.toString());
		return false;
	}
	if(eval(objGold.value)*intTotalWNo > chkCredit){
		alert(overCredit+chkCredit.toString());
		return false;
	}

	var sureStake2 = sureStake.replace("{No}", intTotalWNo);
	sureStake2 = sureStake2.replace("{Gold}", eval(objGold.value)*intTotalWNo);
	if (!confirm(sureStake2))	return false;

	var arrCon = document.WagerForm.WagerContent.value.split("@");
	for(var i = 0; i < arrCon.length; i++){
		var arrCon2 = arrCon[i].split("#");
		arrCon2[2] = objGold.value;
		arrCon[i] = arrCon2.join("#");
	}
	document.WagerForm.WagerContent.value = arrCon.join("@");
	return true;
}

function StartJS(){
	document.WagerForm.StakeMoney.focus();
	if(document.WagerForm.StakeMoney.value != ""){
		if(confirm("{ReWager}")){
			document.WagerForm.submit();
		}
	}
}
//-->
</script>
</head>

<body class="left_body" onload="StartJS()" oncontextmenu="window.event.returnValue=false" ondragstart="window.event.returnValue=false" onselectstart="event.returnValue=false">
<form action="onwager_quick.php" name="WagerForm" method="POST" onsubmit="return FinalCheck()">
<input type="hidden" name="GambleID" value="{GambleIDValue}">
<input type="hidden" name="Bet_Type" value="{Bet_TypeValue}">
<input type="hidden" name="LottoID" value="{LottoIDValue}">
<input type="hidden" name="UserID" value="{UserIDValue}">
<input type="hidden" name="CheckKey1" value="{CheckKeyValue1}">
<input type="hidden" name="CheckKey2" value="{CheckKeyValue2}">
<input type="hidden" name="sid" value="{sid}">
<input type="hidden" name="WagerContent" value="{ShowWagerContent}">
<input type="hidden" name="ChoiceNumber" value="">

<table border="0" cellpadding="0" cellspacing="0" class="left_wc_out">
	<tr class="left_wc_out_top">
		<td class="left_wc_out_top">{LottoName}&nbsp;{BetTypeName}&nbsp;{Title}</td>
	</tr>
<!--使用者資訊//-->
	<tr class="left_wc_out_con">
		<td class="left_wc_out_con">
			<table border="0" cellpadding="0" cellspacing="1" class="left_wc_inner">
			<tr class="left_wc_inner_user">
				<td class="left_wc_inner_user">
					<table border="0" cellpadding="0" cellspacing="0" class="left_wc_user">
					<tr class="left_wc_user">
						<td class="left_wc_user_tip">{Account}</td>
						<td class="left_wc_user_con">{ShowAccount}</td>
					</tr>
					<tr class="left_wc_user">
						<td class="left_wc_user_tip">{Credit}</td>
						<td class="left_wc_user_con">{ShowCredit}</td>
					</tr>
					</table>
				</td>
			</tr>
<!--使用者資訊//-->
<!--注單內容//-->
			<tr class="left_wc_inner_con">
				<td class="left_wc_inner_con">
					<span class="left_wc_con_wagermessage">{WagerMessage}</span><br /><br />
					<span class="left_wc_con_wagercon">{WagerConditions}</span><br /><br />
					<span class="left_wc_con_othermess">{OtherMessage}</span>
				</td>
			</tr>
<!--注單內容//-->
<!--下注金額狀況//-->
			<tr class="left_wc_inner_wg">
				<td class="left_wc_inner_wg">
					<table border="0" cellspacing="0" cellpadding="0" class="left_wc_wg">
                        <tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{StakeMoney}</td>
							<td  class="left_wc_wg_con"><input name="StakeMoney" type="text" class="left_wc_wg" size="10" onkeypress="return CheckNumKey()" onKeyUp="return Calculate()" onchange="Calculate()" value="{ShowStakeMoney}"></td>
						</tr>
						<tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{StakeNo}</td>
							<td class="left_wc_wg_con">{intTotalWNo}</td>
						</tr>
						<tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{MaxGetPayOff}</td>
							<td class="left_wc_wg_con" id="MaxGetPayOff">0</td>
						</tr>
						<tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{MaxWagerPayOff}</td>
							<td class="left_wc_wg_con">{MaxPayOff}</td>
						</tr>
						<tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{MinWagerStake}</td>
							<td class="left_wc_wg_con">{MinStake}</td>
						</tr>
						<tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{MaxBetLimit}</td>
							<td class="left_wc_wg_con">{BetLimit}</td>
						</tr>
						<tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{MaxEventLimit}</td>
							<td class="left_wc_wg_con">{EventLimit}</td>
						</tr>
						<tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{UseEvent}</td>
							<td class="left_wc_wg_con">{UseLimitValue}</td>
						</tr>
						<tr class="left_wc_wg">
							<td class="left_wc_wg_tip">{UseCredit}</td>
							<td class="left_wc_wg_con">{UseCreditValue}</td>
						</tr>
                    </table>
				</td>
			</tr>
<!--下注金額狀況//-->
<!--下注 button//-->
			<tr class="left_wc_inner_bottom">
				<td class="left_wc_inner_bottom">
						<input type="button" class="left_wc_reset" value="{Reset}" onclick="location.href='account.php'">&nbsp;
						<input type="submit" class="left_wc_send" value="{Send}">
				</td>
			</tr>
<!--下注 button//-->
			</table>
		</td>
	</tr>
	<tr class="left_wc_out_bottom">
		<td class="left_wc_out_bottom"></td>
	</tr>
</table>
</form>
</body>
</html>